<template >
    <div class="newsinfo-container">
        <h3 class="title">{{ this.newsInfo.title }}</h3>
        <!-- 子标题 -->
        <p class="subtitle">
            <span>发表时间:{{ this.newsInfo.add_time | dataFormate }}</span>
            <span>点击</span>
        </p>
        <hr>
        <div class="content" v-html="newsInfo.content"></div>

        <commont-box :id="this.id"></commont-box>

    </div>
</template>

<script>

import { Toast } from 'mint-ui'
import  comment from '../subcomponents/common.vue'

export default {
    data(){
      return{
          id: this.$route.params.id ,//将url 传递过来的值 挂载到 data 上 方便后面调用
          newsInfo:{} //新闻详情 对象
      }
    },
    created() {
      this.getNewsInfo();
    },

    methods:{
      getNewsInfo(){
        this.$http.get('api/getnew/'+this.id).then(result => {
          if (result.body.status === 0) {
             this.newsInfo = result.body.message[0]
             console.log(result.body)
          }else{
            Toast('请求失败');
          }
        });
      }
    },

    //注册子控件 
    components:{
      'commont-box':comment,
    }

}
</script>


<style lang="scss" scoped>

.newsinfo-container{
   
   padding: 0px 4px;
   .title{
       font-size: 16px;
       text-align: center;
       margin: 15px 0;
       color: red;
   }
   .subtitle{
       font-size: 13px;
       color: #226aff;
       display: flex;
       justify-content: space-between;
   }
   



}


</style>